package CRUD;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class ReadLineTxt    {
	public static void main(String[] args) {
		File f = new File("C:\\a.txt");
		readFileByLines(f);
	}
	public static String gb2312ToUtf8(String str) {

        String urlEncode = "" ;

        try {
            urlEncode = URLEncoder.encode (str, "UTF-8" );

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return urlEncode;

}
	public static void readFileByLines(File file ) {
		//File file = new File(fileName);
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			//reader.skip(1000);
			String tempString = null;
			int line = 1;
			while ((tempString = reader.readLine()) != null) {
				//tempString = tempString.replaceAll("\\d+\\s*", "   "); 
				
			//	String t =   new String(tempString.getBytes("GBK"), "ISO8859-1");
				if(tempString.contains("TCFail")){
					tempString = "printf(\"functoin = %s  line = %d\",__FUNCTION__,__LINE__);";
				}
				 System.out.println(tempString);
				line++;
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e1) {
				}
			}
		}
	}
}
